<template>
  <div>
    <Chart :cdata="cdata" />
  </div>
</template>

<script>
import Chart from './chart.vue';
import request from "../../../../utils/request";
export default {
  data () {
    return {
      isHistoryObj: {},
      cdata: {
        todayValue: [2,3,2,2],
        yesterdayValue: [2,2,2,2]
      }
    }
  },
  components: {
    Chart,
  },
  props: {
    isHistory: {
      type: Object,
      default: () => {},
    },
  },
  watch: {
    isHistory: {
      handler(newData){
        // console.log("isHistory属性改变了！=》",newData)
        this.isHistoryObj = newData
        request.get("/bigScreen/radarData",{date: newData.date}).then(res=>{
          if(res.success){
            this.cdata = res.result
          }
          else {
            this.$message.error(res.message)
          }
        })
      },
      immediate: true,
      deep: true,
    }
  },
  mounted () {

    let that = this
    this.ws = this.$store.state.websocketModule.ws
    this.ws.subscribe('/bigScreen/radarData', function (message){//有教程说topic前面必须带一个/user前缀，但是我没加也没事啊
      // debugger
      that.cdata = JSON.parse(message.body)
    });
  },
  methods: {
  }
}
</script>

<style lang="scss" scoped>
</style>